#!/usr/bin/env python

def build(bld):
    for arch in bld.lst_variants:
        if arch == 'default': continue

        bld.add_subdirs('libavutil libavdevice libavformat libavfilter libavcodec llrint')
        libs = 'avutil_' + arch + ' pthread_stub_'+arch # + ' interrupt_' + arch + ' avutil_' + arch
        obj = bld.new_task_gen(features='cc cprogram')
        obj.env = bld.env_of_name(arch).copy()
        obj.add_objects = 'avcodec_' + arch + ' lrint_' + arch + ' avformat_' + arch + ' avdevice_' + arch
        obj.find_sources_in_dirs('.')
        #obj.source = """
        #ffmpeg.c cmdutils.c
        #"""
        obj.target = 'ffmpeg'
        obj.includes     = """. ./libavcodec ./libavdevice ./libavfilter ./libavformat ./libavutil
            ./libswscale"""
        obj.uselib_local = libs
        obj.env.append_unique('CPPFLAGS', bld.env_of_name(arch)['FFMPEG_SUBDIRS_ADDITIONALFLAGS'])
        linkFlags = [ '-Wl,--warn-common', '-Wl,-Bsymbolic']
        obj.env.append_unique('LINKFLAGS', linkFlags)

